package com.yaowk.service.mall.clothing.entity;

import com.yaowk.service.common.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

/**
 * 订单
 */
@Getter
@Setter
@ToString
@Entity
@DynamicInsert
@DynamicUpdate
public class CmOrder extends BaseEntity<Long> {

    @Column(nullable = false)
    private Byte status; // 订单状态
    @Column(unique = true, nullable = false)
    private String orderNo; // 订单号
    @CreationTimestamp
    @Column(updatable = false, nullable = false)
    private Date createTime; // 下单时间
    @Column(nullable = false)
    private BigDecimal amount; // 金额
    private Byte payType; // 支付方式
    private Date payTime; // 支付时间
    private String expressNo; // 快递单号
    @ColumnDefault("0")
    private Byte serviceStatus; // 维权状态
    private String consignee; // 收件人
    private String phone; // 收件人电话
    private String address; // 收件地址

    @ManyToOne
    private CmMember member; // 会员
    @OneToMany
    private Set<CmGoods> goods; // 商品
    @ManyToOne
    private CmStore store; // 商铺
    @ManyToOne
    private CmPay pay; // 支付单
    @OneToMany
    private Set<CmRefund> refunds; // 退款单
}
